$(function (){
	CheckStati();

	CheckHomeAnnoun();

	try {
		CheckTopAd();
	}catch (e) { }

	try {
		CheckQqServer();
	}catch (e) { }

	try{
		CheckMetaCSP();
	}catch (e){}

	CheckSubWeb404();
	CheckSearch();
	CheckMark();
	CheckMessage();

	try{
		CheckHomeDomain();
	}catch (e){}

	WindowHeight(0);setTimeout("WindowHeight(-1)",500);

});

// 检测表单
function CheckForm(){
	try{
		if ($id('searchArea5').checked && $id('searchArea5_addi2').value==""){
			alert("开启百度站内搜索项，搜索引擎ID不能为空");$id('searchArea5_addi2').focus();return false;
		}
	}catch (e){}

}


// 检测统计代码框
function CheckStati(){
	if ($id('isStati1').checked){
		$id("statiBox").style.display="";
	}else{
		$id("statiBox").style.display="none";
	}
	WindowHeight(0);
}



// 检查是否开启导航下面文字广告
function CheckTopAd(){
	if ($id('isTopAd0').checked){
		$id('topAdBox').style.display="none";
	}else{
		$id('topAdBox').style.display="";
	}
	WindowHeight(0);
}


// 检测首页公告栏目
function CheckHomeAnnoun(){
	if ($id('isHomeAnnoun0').checked){
		$id("homeAnnounBox").style.display="none";
	}else{
		$id("homeAnnounBox").style.display="";
	}
	WindowHeight(0);
}


// 检查列表页错误跳转
function CheckSubWeb404(){
	var checkedJud=false;
	for (var i=0; i<$name('subWeb404').length; i++){
		if ($name('subWeb404')[i].checked){
			checkedJud=true;break;
		}
	}
	if (checkedJud==false){
		$id('subWeb404Other').checked=true;
	}
	if ($id('subWeb404Other').checked==true){
		$id('subWeb404NewBox').style.display='';
		if ($id('subWeb404New').value==""){ $id('subWeb404New').value="other.html"; }
	}else{
		$id('subWeb404NewBox').style.display='none';
	}
}

// 检测搜索页
function CheckSearch(){
	if ($id('isSearch0').checked){
		$id("searchBox").style.display="none";
	}else{
		$id("searchBox").style.display="";
	}
	WindowHeight(0);
}

// 检测标签页
function CheckMark(){
	if ($id('isMark0').checked){
		$id("markBox").style.display="none";
	}else{
		$id("markBox").style.display="";
	}
	WindowHeight(0);
}

// 检测是否开启留言板
function CheckMessage(){
	if ($id("isMessage0").checked){
		$id("messageBox").style.display="none";
		$id("messageCloseBox").style.display="";
	}else{
		$id("messageBox").style.display="";
		$id("messageCloseBox").style.display="none";
	}
	WindowHeight(0);
}

// 检测QQ客服代码框
function CheckQqServer(){
	if ($id('isQqServer0').checked){
		$id("qqServerBox").style.display="none";
	}else{
		$id("qqServerBox").style.display="";
	}
	WindowHeight(0);
}

function InputDefShare(str){
	if (str=="qqServerCode"){
		$id(str).value=""+
			"<dl>\n"+
			"	<dt>客服工作时间</dt>\n"+
			"	<dd class=\"font1\">周一至周日</dd>\n"+
			"	<dd class=\"font1\">9:00 - 24:00</dd>\n"+
			"\n"+
			"	<dt>客服团队</dt>\n"+
			"	<dd><a href=\"https://wpa.qq.com/msgrd?v=3&uin=QQ号&site=网站名称&menu=yes\" target=\"_blank\"><img height=\"17\" alt=\"点击这里给我发消息\" hspace=\"2\" src=\"https://wpa.qq.com/pa?p=1:QQ号:17\" width=\"25\" align=\"absBottom\" border=\"0\" />客服--李某</a></dd>\n"+
			"	<dd><a href=\"https://wpa.qq.com/msgrd?v=3&uin=QQ号&site=网站名称&menu=yes\" target=\"_blank\"><img height=\"17\" alt=\"点击这里给我发消息\" hspace=\"2\" src=\"https://wpa.qq.com/pa?p=1:QQ号:17\" width=\"25\" align=\"absBottom\" border=\"0\" />客服--张某</a></dd>\n"+
			"	<dd><a href=\"https://wpa.qq.com/msgrd?v=3&uin=QQ号&site=网站名称&menu=yes\" target=\"_blank\"><img height=\"17\" alt=\"点击这里给我发消息\" hspace=\"2\" src=\"https://wpa.qq.com/pa?p=1:QQ号:17\" width=\"25\" align=\"absBottom\" border=\"0\" />客服--林某</a></dd>\n"+
			"\n"+
			"	<dt>QQ交流群</dt>\n"+
			"	<dd class=\"font2\">群1：111111111</dd>\n"+
			"	<dd class=\"font2\">群2：222222222</dd>\n"+
			"	<dd class=\"font2\">群3：333333333</dd>\n"+
			"	<dd class=\"font2\">群4：444444444</dd>\n"+
			"</dl>"+
			"";
	}
}


// 内容安全策略(CSP) 快捷设置
function CheckMetaCSP(){
	styleStr = '';
	if ($id('csp_default') && $id('csp_default').value.length > 0){
		styleStr += '<span style="color:red;">default-src</span> <span style="color:#000;">'+ $id('csp_default').value +'</span>; ';
	}
	if ($id('csp_script') && $id('csp_script').value.length > 0){
		styleStr += '<span style="color:red;">script-src</span> <span style="color:#000;">'+ $id('csp_script').value +'</span>; ';
	}
	if ($id('csp_style') && $id('csp_style').value.length > 0){
		styleStr += '<span style="color:red;">style-src</span> <span style="color:#000;">'+ $id('csp_style').value +'</span>; ';
	}
	if ($id('csp_img') && $id('csp_img').value.length > 0){
		styleStr += '<span style="color:red;">img-src</span> <span style="color:#000;">'+ $id('csp_img').value +'</span>; ';
	}
	if ($id('csp_media') && $id('csp_media').value.length > 0){
		styleStr += '<span style="color:red;">media-src</span> <span style="color:#000;">'+ $id('csp_media').value +'</span>; ';
	}
	if ($id('csp_font') && $id('csp_font').value.length > 0){
		styleStr += '<span style="color:red;">font-src</span> <span style="color:#000;">'+ $id('csp_font').value +'</span>; ';
	}
	if ($id('csp_object') && $id('csp_object').value.length > 0){
		styleStr += '<span style="color:red;">object-src</span> <span style="color:#000;">'+ $id('csp_object').value +'</span>; ';
	}
	if ($id('csp_child') && $id('csp_child').value.length > 0){
		styleStr += '<span style="color:red;">child-src</span> <span style="color:#000;">'+ $id('csp_child').value +'</span>; ';
	}
	if ($id('csp_frame') && $id('csp_frame').value.length > 0){
		styleStr += '<span style="color:red;">frame-src</span> <span style="color:#000;">'+ $id('csp_frame').value +'</span>; ';
	}
	/*
	if ($id('csp_connect') && $id('csp_connect').value.length > 0){
		styleStr += 'connect-src '+ $id('csp_connect').value +'; ';
	}
	if ($id('csp_worker') && $id('csp_worker').value.length > 0){
		styleStr += 'worker-src '+ $id('csp_worker').value +'; ';
	}
	if ($id('csp_manifest') && $id('csp_manifest').value.length > 0){
		styleStr += 'manifest-src '+ $id('csp_manifest').value +'; ';
	}
	*/
	if (styleStr.length > 0){
		styleStr = '&lt;meta http-equiv="Content-Security-Policy" content="'+ styleStr +'"&gt;<br /><span style="color:green;"><b>请将上面生成的meta标签内容复制黏贴到下面【PC端meta标签区域】里</b></span>';
	}

	$id('metaCSPdiv').innerHTML = styleStr;
	WindowHeight(0);
}


// 内容安全策略(CSP) 快捷选择
function PlanMetaCSP(){
	var default_	= "";
	var script_		= "";
	var style_		= "";
	var img_		= "";
	var media_		= "";
	var font_		= "";
	var object_		= "";
	var child_		= "";
	var frame_		= "";
	var connect_	= "";
	var worker_		= "";
	var manifest_	= "";
	switch ($id('cspPlan').value){
		case 'self':
			default_	= "'none'";
			script_		= "'self' 'unsafe-inline' data:";
			style_		= "'self' 'unsafe-inline' data:";
			img_		= "'self' data:";
			media_		= "'self' data:";
			frame_		= "'self' data:";
			font_		= "'self' data:";
			object_		= "'self' data:";
			child_		= "'self' data:";
			break;
	
		case 'safe':
			default_	= "";
			script_		= "'self' 'unsafe-inline' 'unsafe-eval' data: *.wx.qq.com *.bdstatic.com *.zhanzhang.baidu.com *.51.la *.baidu.com";
			style_		= "'self' 'unsafe-inline' data:";
			img_		= "";
			media_		= "";
			frame_		= "'self'";
			font_		= "'self' data:";
			object_		= "'none'";
			child_		= "'self' data:";
			break;
	
	}

	if ($id('csp_default')){	$id('csp_default').value	= default_; }
	if ($id('csp_script')){		$id('csp_script').value		= script_; }
	if ($id('csp_style')){		$id('csp_style').value		= style_; }
	if ($id('csp_img')){		$id('csp_img').value		= img_; }
	if ($id('csp_media')){		$id('csp_media').value		= media_; }
	if ($id('csp_frame')){		$id('csp_frame').value		= frame_; }
	if ($id('csp_font')){		$id('csp_font').value		= font_; }
	if ($id('csp_object')){		$id('csp_object').value		= object_; }
	if ($id('csp_child')){		$id('csp_child').value		= child_; }
	// if ($id('csp_connect')){	$id('csp_connect').value	= connect_; }
}


// 检测首页域名窗口
function CheckHomeDomain(){
	if ($id('isHomeDomain0').checked){
		$id("homeDomainBox").style.display="none";
	}else{
		$id("homeDomainBox").style.display="";
	}
	WindowHeight(0);
}
